Skip to main content

GetText

Returns a text from the text run.

Syntax

expression.GetText(oPr, oPr.NewLineSeparator, oPr.TabSymbol);

expression - A variable that represents a ApiRun class.

Parameters

NameRequired/OptionalData typeDefaultDescription
oPrRequiredobjectThe resulting string display properties.
oPr.NewLineSeparatorOptionalstring'\r'Defines how the line separator will be specified in the resulting string.
oPr.TabSymbolOptionalstring'\t'Defines how the tab will be specified in the resulting string.

Returns

string

Example

This example returns a text from the text run.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("\tThis is a text run");
paragraph.AddElement(run);
let text = run.GetText({"NewLineSeparator": "\r", "TabSymbol": "\t"});
paragraph = Api.CreateParagraph();
paragraph.AddText("The text of the specified run: " + text);
doc.Push(paragraph);